<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %><%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%	
WebAction webAction = new WebAction(request, response);

String action = webAction.getParameterString("action");
BBSService bbsService = BBSService.getInstance();
if(action != null) {
	if(action.equals("add")){
		String title = webAction.getParameterString("title");
		String description = webAction.getParameterString("description");
		
		BBSBean bbs = new BBSBean();
		bbs.setTitle(title);
		bbs.setDescription(description);
		
		if(bbsService.addBBSBean(bbs)) {
			response.sendRedirect("bbs.jsp?msg=addSuccess");
			return;
		} else {
			response.sendRedirect("bbs.jsp?msg=addFailure");
			return;
		}
		
	} else if(action.equals("delete")) {
		int id = webAction.getParameterInt("id");
		if(bbsService.deleteBBSById(id)){
			response.sendRedirect("bbs.jsp?msg=deleteSuccess");
			return;
		} else {
			response.sendRedirect("bbs.jsp?msg=deleteFailure");
			return;
		}
		
		
	}
}


List<BBSBean> list = bbsService.getBBSList();
request.setAttribute("list",list);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="com.yymmarket.forum.bbs.BBSService"%>
<%@page import="com.yymmarket.framework.WebAction"%>
<%@page import="java.util.List"%>
<%@page import="com.yymmarket.forum.bbs.BBSBean"%>
<%@page import="com.yymmarket.util.SqlUtil"%>
<%@page import="com.yymmarket.util.db.DbOperation"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>版块管理页面</title>
<link href="../../css/common.css" rel="stylesheet" type="text/css">
</head>
<body>
<table>
	<tr>
		<td>id</td>
		<td>标题</td>
		<td>描述</td>
		<td>总帖子数量</td>
		<td>今日帖子数</td>
		<!-- <td>mark</td>
		<td>type</td>
		<td>foreigneId</td> -->
		<td>建立时间</td>
		<td>操作</td>
	</tr>
	<c:forEach items="${requestScope.list}" var="bean">
	<tr>
		<td>${bean.id}</td>
		<td>${bean.title}</td>
		<td>${bean.description }</td>
		<td>${bean.totalCount }</td>
		<td>${bean.todayCount }</td>
		<!--<td>${bean.mark }</td>
		<td>${bean.type }</td>
		<td>${bean.foreignerId}</td> -->
		<td><fmt:formatDate value="${bean.createTime}"  pattern="yyyy-MM-dd"/></td>
		<td><a href="bbs.jsp?nav=update">修改</a>|<a href="bbs.jsp?action=delete&id=${bean.id}">删除</a>|<a href="bbsManage.jsp?type=11&id=${bean.id}">用户管理</a></td>
	</tr>
	</c:forEach>
</table>
<br/><br/>
增加版块<br/>
<form action="bbs.jsp?action=add" method="post">
标题:<input type="text" name="title" /><br/>
描述:<textarea name="description" rows="5" cols="20"></textarea><br/>
<input type="submit" value="增加"/>
</form>
</body>
</html>